package org.linlinjava.litemall.admin.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.linlinjava.litemall.admin.beans.annotation.LogAnno;
import org.linlinjava.litemall.admin.service.AdminPayMemberUserLogService;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.core.validator.Order;
import org.linlinjava.litemall.core.validator.Sort;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户日志管理支付成员控制器
 *
 * @author yliyun
 * @date 2022/09/14
 */
@Api(tags = "用户日志管理支付成员控制器")
@RestController
@RequestMapping("/admin/payMemberUserLog")
@Validated
public class AdminPayMemberUserLogController extends ResponseUtil {

    /**
     * 管理支付会员用户日志服务
     */
    @Autowired
    private AdminPayMemberUserLogService adminPayMemberUserLogService;

    /**
     * 列表
     *
     * @param userName     用户名
     * @param memberName   成员名
     * @param purchaseType 购买类型
     * @param buyTime      争取时间
     * @param payType      支付类型
     * @param page         页面
     * @param limit        限制
     * @param sort         排序
     * @param order        订单
     * @return {@link Object}
     */
    @ApiOperation(value = "付费会员用户日志列表")
    @GetMapping("list")
    @LogAnno
    public Object list(String userName, String memberName,
                       Byte purchaseType,String buyTime,Byte payType,@RequestParam(defaultValue = "1") Integer page,
                       @RequestParam(defaultValue = "10") Integer limit,
                       @Sort @RequestParam(defaultValue = "add_time") String sort,
                       @Order @RequestParam(defaultValue = "asc") String order){
        return adminPayMemberUserLogService.queryPayMemberUserLog(userName,memberName,purchaseType,buyTime,payType,page,limit,sort,order);
    }


    /**
     * TODO 指定用户查询付费会员日志列表
     * 付费会员明细
     * @param userId       用户id
     * @param page         页面
     * @param limit        限制
     * @param sort         排序
     * @param order        订单
     * @return {@link Response}
     */
    @ApiOperation(value = "用户付费会员日志列表")
    @GetMapping("listById")
    @LogAnno
    public Response userList(
            @RequestParam("userId")String userId,
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer limit,
            @Sort @RequestParam(defaultValue = "add_time") String sort,
            @Order @RequestParam(defaultValue = "asc") String order
    ){
        return adminPayMemberUserLogService.queryPayMemberUserLogByUid(userId,page,limit,sort,order);
    }




}
